package org.dea.facade;

import java.io.File;

import junit.framework.TestCase;

import org.dea.util.CheckSummer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class AllFacadesMakerTest extends TestCase  {
	
	String fileGenerated1 = "test/SwitchSimple.java";
	String fileExpected1 = "test2/SwitchSimple.java";
	String fileGenerated2 = "test/RMISimple.java";
	String fileExpected2 = "test2/RMISimple.java";
	String fileGenerated3 = "test/IFSimple.java";
	String fileExpected3 = "test2/IFSimple.java";

	@Before
	public void setUp() throws Exception {
		new File(fileGenerated1).delete();
		new File(fileGenerated2).delete();
		new File(fileGenerated3).delete();
	}

	@After
	public void tearDown() throws Exception {
//		new File(fileGenerated1).delete();
//		new File(fileGenerated2).delete();
//		new File(fileGenerated3).delete();
	}

	@Test
	public void testGenerateFacade() throws Exception {
		new AllFacadesMaker("test/xml/onlyAlpha.xml").generateFacade(new File("test"), "somepack.Simple");
//		new AllFacadesMaker("test/xml/onlyAlpha.xml").generateFacade(new File("test"), "Simple");
		assertTrue(new File(fileGenerated1).exists());
		assertTrue(new File(fileGenerated2).exists());
		assertTrue(new File(fileGenerated3).exists());
		assertEquals(new File(fileExpected1).length(),new File(fileGenerated1).length());
		assertEquals(new File(fileExpected2).length(),new File(fileGenerated2).length());
		assertEquals(new File(fileExpected3).length(),new File(fileGenerated3).length());
		assertEquals( CheckSummer.createStringChecksum(fileExpected1), CheckSummer.createStringChecksum(fileGenerated1) );
		assertEquals( CheckSummer.createStringChecksum(fileExpected2), CheckSummer.createStringChecksum(fileGenerated2) );
		assertEquals( CheckSummer.createStringChecksum(fileExpected3), CheckSummer.createStringChecksum(fileGenerated3) );
	}

}
